<?php
namespace app\api\controller;

class Index extends Common
{
	public function index(){
	// $RootDir = $_SERVER['DOCUMENT_ROOT'];

		$path ='../app/api/controller'; //你想要哪个文件夹下面的注释生成对应的API文档
		$api = \OpenApi\scan($path);
		header('Content-Type: application/x-yaml');
		$api_json_path = './swagger.json';

		$res = file_put_contents($api_json_path, $api->toYaml());
		if ($res == true) {
			//return redirect('http://127.0.0.1/tpapi/dist/index.html');
			//跳转至swwager当前项目在线文档页面，默认获取当前项目域名
			return redirect(Request::domain() . '/tpapi/dist/index.html');
		}
	}
}